package com.bgs.service.impl;

import com.bgs.common.R;
import com.bgs.pojo.FocusOn;
import com.bgs.mapper.FocusOnMapper;
import com.bgs.pojo.Store;
import com.bgs.pojo.vo.ThreeFriend;
import com.bgs.pojo.vo.ThreeFriendGet;
import com.bgs.service.FocusOnService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 关注表 服务实现类
 * </p>
 *
 * @author Asia
 * @since 2021-09-14
 */
@Service
public class FocusOnServiceImpl extends ServiceImpl<FocusOnMapper, FocusOn> implements FocusOnService {
    @Resource
    private FocusOnMapper focusOnMapper;

    @Override
    public R ThreeStoreBeforeUser(String beforeUserId) {
        List<ThreeFriend> friend = new ArrayList<ThreeFriend>();
        List<Store> li = focusOnMapper.ThreeStoreBeforeUser(beforeUserId);
        for (Store store : li) {
            ThreeFriend l = new ThreeFriend();
            l.setUuid(store.getBeforeUserId().toString());
            l.setName(store.getStoreName());
            l.setAvatar(store.getStoreImg());
            friend.add(l);
        }
        return R.ok().data("data", friend);
    }

    @Override
    public R ThreeUserStore(String beforeUserId) {
        ThreeFriendGet friend = new ThreeFriendGet();
        Store s = focusOnMapper.ThreeUserStore(beforeUserId);
        friend.setUuid(beforeUserId);
        friend.setName(s.getStoreName());
        friend.setAvatar(s.getStoreImg());
        return R.ok().data("data", friend);
    }
}
